var account = {
	initLoginForm:function(){
    	var options = {
            dataType : 'json',
            beforeSerialize : function(form, options) {
                options.url = 'account/login.action';
            },
            beforeSubmit : function() {
            	if(!$('#userName').val()){
            		alert("帐号不能为空！");
                    return false;
                }
                if(!$('#password').val()){
            		alert("密码不能为空！");
                    return false;
                }
                $('#signForm').attr('action', 'account/login.action');
                return true;
            },
            success : function(data) {
                if(data.result.success==true){
                	if(navigator.cookieEnabled){
					   if(data.exist=='yes'){
	                		$.cookie('czryUuid',data.czryuuid);
	                		$.cookie('czryName',data.czryname);
	                		$.cookie('swjgUuid',data.swjguuid);
	                		$.cookie('swjgName',data.swjgname);
	                        location.href = data.redirectUrl;
	                	}else{
	                		alert("账号或密码错误！");
	                    	$('#loginErrorTips').html('');
	                        $('#loginError').show();
	                	}
					}else{
						alert("对不起，您的浏览器Cookie功能被禁用，请先开启。");
					}
                }else{
            		alert("系统异常，请稍候再试！");
                }
            }
        };
        
        $('#signForm').submit(function() {
            $(this).ajaxSubmit(options);
            return false;
        });
    },
    getTaxpayerInfo:function(){
    	if($('#taxpayerId').val()){
        	var mainFrameDocument = parent.frames("mainFrame").document;
    		$.ajax({
	            type: "GET",
	            url: config.baseURL + "common/sendHttp.action",
	            cache:false,
	            dataType: "xml",
	            data : {
	                "url":config.interfaceCenterBaseURL + "/interface/getTaxpayerInfo.action",
	                "taxpayer":$('#taxpayerId').val(),
	                "typeId":$('#formName', document.frames('formPage').document).val()
	            },
	            success: function(xml){
	            	$(xml).find("resultInfo").each(function(i){
	                    var name = $(this).attr("name");
	                    var value = $(this).text();
	                    $('#'+name, document.frames('formPage').document).val(value); 
	                    $('#'+name, document.frames('formPage').document).removeClass('placeholder');
	                    if(name=='nsrsbh'){
	                		if($('#nsrsbhTr',document.frames('formPage').document).attr('size') > 0){
	                    		for(var i=0;i<value.length;i++){
	                    			$('#nsrsbhTd'+(i+1),document.frames('formPage').document).text(value.substr(i,1));
	                    		}
	                    	}
	                    }
	                });
	            }
       		});
	       // $('#taxpayerId').val('');
    	}
	}
};